<?php
require 'settings.php';
require 'db.php';

if( isset( $_POST['pricelist_id'] ) )
{
	$pl_id = $_POST['pricelist_id'];
}

if( isset( $_POST['pricelist_name'] ) )
{
	$pl_name = $_POST['pricelist_name'];
}
?>

<html>
<head>
<title><?php echo $corp_name?> Industry Manager - Materials for pricelist "<?php echo $pl_name ?>" </title>

<style type="text/css">
table, th, td
{
border: 1px solid black;
border-collapse: collapse;
padding: 5px;
}
</style>

</head>
<body>
<h1 class=c_page_title>Materials for pricelist "<?php echo $pl_name ?>"</h1>


<form name="get_materials" action="display_materials.php" method="post" >
<input type="hidden" name="pricelist_name" value="<?php echo $pl_name ?>" />
<table>
<tr><td style="font-weight:bold">Name</td><td style="font-weight:bold">Count</td></tr>

<?php
$pricelist_get->bind_param( 'i', $pl_id );
$pricelist_get->bind_result( $prod_it, $item_id, $item_name, $item_build_cost, $item_price, $item_replacement, $item_mat_volume );
$pricelist_get->execute();
while( $pricelist_get->fetch() )
{
	echo '<tr><td style="text-align:left">'.$item_name.'</td>';
	echo '<td style="text-align:right">';
	echo '<input type="text" value="0" name="prod_'.$prod_it.'" />';
	echo '</td></tr>';
}
$pricelist_get->close();

?>
</table>
<input type="submit" value="Calculate materials for these products" />
</form>

<br />
<a href="view_pricelists.php">View pricelists</a><br />
<a href="index.php">Back to main screen</a>
</body>
</html>